<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ include file="/WEB-INF/views/include/constrant.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>接送机</title>
<script src="${ctxStatic }/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${ctxStatic }/gov/js/jquery.validate.js" ></script>
<script type="text/javascript" src="${ctxStatic }/gov/js/messages_zh.js" ></script>
<script type="text/javascript" src="${ctxStatic }/gov/js/cityselect.js" ></script>
<link rel="stylesheet" href="${ctxStatic }/gov/css/govairport.css" />
<link href="${ctxStatic }/cityselector/cityselect.css" rel='stylesheet'type='text/css' />
<script type="text/javascript">
	$(function() {
		// 机场
		$.post('${ctxFront}/info/site/siteJson',{spottypes:'9'}, function(data) {
			new Vcity.CitySelector({input:'departcity_sitename3',cityData:data});
		});
		// 送达城市
		$.post('${ctxFront}/info/site/siteJson',{spottypes:'0'}, function(data) {
			new Vcity.CitySelector({input:'destcity_sitename3',cityData:data});
		});
		$('.airportRentTab').click(function(){
			$('#airportRentType').val($(this).attr('data-value'));
		});
	})
</script>
</head>
<body>
		 <%@include file="../index/head.jsp" %>
		  <div id="govaircraft">
		    	  <div class="gov-air-main">
		    	  	  <div class="gov-air-banner">
		    	  	  	  <img src="${ctxStatic }/gov/img/govair.jpg" />
		    	  	  </div>
		    	  	  <div class="gov-air-list">
		    	  	  	  <div class="gov-air-tit">
		    	  	  	  	  <p class="clearfix gov-air-query">
		    	  	  	  	  	<span class="pick-air pick-send" data-value="接机">接机</span>
		    	  	  	  	  	<span class="send-air" data-value="送机">送机</span>
		    	  	  	  	  </p>
		    	  	  	  </div>
		    	  	  	  <div class="gov-air-klo">
		    	  	  	  	<form>
		<input id="airportRentType" type="hidden" name="tabType" value="接机"/>    	  	  	  		
		    	  	  	  	 <div class="gov-klo-box">
		    	  	  	  	     <div class="gov-air-il">
		    	  	  	  	     	  <span class="g-airport">出发机场：</span>
		<input type="text" id="departcity_sitename3" class="g-a-pt" name="departcity.sitename" 
		value="" placeholder="请选择机场" autocomplete="off">
		<input type="hidden" name="departcity.siteid" value="">
		    	  	  	  	     </div>
		    	  	  	  	     <div class="gov-air-il">
		    	  	  	  	     	  <span class="g-aircity">抵达地点：</span>
		    	  	  	  	     	  <input type="text" placeholder="请选择到达城市" class="g-a-pd" id="destcity_sitename3" 
		    	  	  	  	     	  	data-autocity="yes" name="destcity.sitename" autocomplete="off"
		    	  	  	  	     	  	style="width:80px"/>
		<input type="hidden" name="destcity.siteid"  id="destcity.siteid" value="${tRentproduct.destcity.siteid }">
		    	  	  	  	     	  <input type="text" placeholder="请输入具体地址" id="suggestId" name="aboardAddress"
		    	  	  	  	     	  	class="g-a-pd" style="width:175px"/>
<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
		    	  	  	  	     </div>
		    	  	  	  	      <div class="gov-air-il">
		    	  	  	  	     	  <span>出发时间：</span>
		    	  	  	  	     	 <input type="text" placeholder="选择日期" class="custom-day Wdate" name="fromdateStr" value="<fmt:formatDate value="${defaultTime}" pattern="yyyy-MM-dd HH:mm"/>"
	  	   	  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false,maxDate:'${maxDay }',minDate:'%y-%M-%d'})" id="coutm-time" readonly="readonly"/>
		    	  	  	  	     </div>
		    	  	  	  	  </div>
		    	  	  	  	  <div class="gov-air-cur">
		    	  	  	  	  	   <input type="submit" value="查询" id="airportsearch" />
		    	  	  	  	  </div>
		    	  	  	  	</form>
		    	  	  	  </div>
		    	  	  </div>
		    	  </div>
		    </div>
		 <%@include file="../index/foot.jsp" %>
	</body>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=kOQ8j9rd2ATw2R54boLMFUalu3gGNGDO&s=1"></script>
	<script type="text/javascript" src="${ctxStatic }/index/js/map.js"></script>
<script type="text/javascript">
//接送机提交
var km = 0;
var time = 0;
$(function(){
	$("#airportsearch").click(function(){
		if($('#departcity_sitename3').val()=="") {
			alert("机场不能为空");
			return false;
		}
		if($('#destcity_sitename3').val()=="") {
			alert("城市不能为空");
			return false;
		}
		if($('#suggestId').val()=="") {
			alert("请输入详细地址");
			return false;
		}
		var x= $('#suggestId').val();
		var y = $('#departcity_sitename3').val()
		var map = new BMap.Map("allmap");
var output = "从"+y+"到"+x+"驾车预计需要";
var searchComplete = function (results){
	if (transit.getStatus() != BMAP_STATUS_SUCCESS){
		return ;
	}
	var plan = results.getPlan(0);
	output += plan.getDuration(true) + "\n";                //获取时间
	time = plan.getDuration(true);
	$('#maptime').val(time)
	output += "总路程大约为：" ;
	output += plan.getDistance(true) + "\n";             //获取距离
	km = plan.getDistance(true);
	$('#mapkm').val(km);
}
var transit = new BMap.DrivingRoute(map, {renderOptions: {map: map},
	onSearchComplete: searchComplete,
	onPolylinesSet: function(){        
		//$("#distance").html(output);
		$("#mes").val(output);
}});
transit.search(x, y);
window.setTimeout(submitform, 1500); 
function submitform() 
{
	var $time = $("#fromdateStr").val()+" "+$("#time").val();
	$.post("${ctxFront}/sms/checkTime","time="+$time,function(d){
		if(d==1){//"距离发车时间不足2小时，请重新选择发车时间"
			alert("距离发车时间不足2小时，请重新选择出发时间");
			return false;
		}else{
			$('#airportRentForm').submit();
		}
	});
} 
})
	})
</script>
 </html>